import 'package:flutter/material.dart';
import 'package:flutter_app/http/DioRepository.dart';
import 'package:flutter_app/model/ComicsChapterData.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ComicsPageViewModel extends ChangeNotifier {

  List<ComicsChapterData> list = [];

  ///<p>获取章节</p>
  ///[fictionId] 漫画id
  getChapter(String cartoonId) {
    DioRepository().getComicsChapters(cartoonId, onSuccess: (rep) {
      var value = BaseComicsChapterData.fromJson(rep);
      if (value.code == 0) {
        list.addAll(value.data.data);
        notifyListeners();
      } else {
        Fluttertoast.showToast(msg: value.msg);
      }
    });
  }
}